package com.ziyun.erp.modules.production.operate;

import com.ziyun.erp.modules.production.operate.entity.AllotStateEntity;
import com.ziyun.erp.modules.production.operate.entity.AuditStateEntity;
import com.ziyun.erp.modules.production.operate.entity.LogisticsStateEntity;
import io.renren.common.utils.R;

/**
 * @author guizhao
 * @Title: 订单状态变化环境
 * @ProjectName ziyun-service-erp
 * @Description:
 *              审核 -->  分配
 * 生产状态, forward :1.待生产 -->  2.生产中 -->  3.生产完成  ;
 *                            rollback: 3.生产完成 --> 2.生产中 --> 1.待生产 --> 4.取消
 * @date 2018-09-08 15:33
 */
public class ErpOrderStateContext {

    /**
     * 阳逻工厂ID
     */
    public static int YANGLUO_SUPP_ID = 343;
    /**
     * 紫云网会员ID
     */
    public static int ZIYUN_USER_ID = 683810;
    /**
     * 紫云SELLER_ID
     */
    public static int ZIYUN_SELLER_ID = 1;
    /**
     * 紫云外协名称
     */
    public static String ZIYUN_SUPP_NAME = "中浩紫云";
    /**
     * 紫云配价工厂ID
     */
    public static Long ZIYUN_FACTORY_ID = 20L;
    /**
     * 麦彩传媒（深圳）有限公司 ID ， 严欧负责分配到商户订单验货确定
     */
    public static Long MAICAI_SELLER_ID = 1147L;
    /**
     * 抽象接口
     */
    ErpOrderState erpOrderState;
    /**
     * 订单分配参数
     */
    AllotStateEntity allotStateEntity;
    /**
     * 订单审核参数
     */
    AuditStateEntity auditStateEntity;
    /**
     * 订单物流参数
     */
    LogisticsStateEntity logisticsStateEntity;
    /**
     * 生产单ID
     */
    private Integer productionId;

    public ErpOrderStateContext(ErpOrderState erpOrderState){
        this.erpOrderState = erpOrderState;
    }

    public ErpOrderStateContext(ErpOrderState erpOrderState, AllotStateEntity allotStateEntity){
        this (erpOrderState);
        this.allotStateEntity = allotStateEntity;
    }

    public ErpOrderStateContext(ErpOrderState erpOrderState, AuditStateEntity auditStateEntity){
        this (erpOrderState);
        this.auditStateEntity = auditStateEntity;
    }

    public ErpOrderStateContext(ErpOrderState erpOrderState, LogisticsStateEntity logisticsStateEntity){
        this (erpOrderState);
        this.logisticsStateEntity = logisticsStateEntity;
    }

    public ErpOrderStateContext(ErpOrderState erpOrderState, Integer productionId){
        this (erpOrderState);
        this.productionId = productionId;
    }

    /**
     * 审核
     * @return
     */
    public R audit(){
        return erpOrderState.audit(auditStateEntity);
    }

    /**
     * 分配
     * @return
     */
    public R allot(){
        return erpOrderState.allot(allotStateEntity);
    }

    /**
     * 确认收货
     * @return
     */
    public R receive(){
        return erpOrderState.receive(productionId);
    }

    /**
     * 添加物流
     * @return
     */
    public R addLogistics(String userId, String createName){
        return erpOrderState.addLogistics(logisticsStateEntity,userId, createName);
    }

    /**
     * 审核完成
     * @return
     */
    public R allotPriceFinish(){
        return erpOrderState.allotPriceFinish(productionId);
    }

    /**
     * 取消分配
     * @return
     */
    public R cancleAllot(){
        return erpOrderState.cancleAllot(productionId);
    }

}
